<template>
  <div class="cart-item">
    <check-button :isChecked="cartItem.checked" @click.native="checkBtnClick()"></check-button>
    <div class="goods-img">
      <img :src="cartItem.image" alt />
    </div>
    <div class="goods-info">
      <div class="title">{{cartItem.title}}</div>
      <div class="desc">{{cartItem.desc}}</div>
      <div class="price-count">
        <div class="price">{{cartItem.price}}</div>
        <div class="count">X{{cartItem.count}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import CheckButton from '@/components/content/checkbutton/CheckButton'

export default {
  components: {
    CheckButton,
  },
  props: {
    cartItem: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  methods: {
    checkBtnClick() {
      this.cartItem.checked = !this.cartItem.checked
    },
  },
}
</script>

<style scoped>
.cart-item {
  width: 100%;
  padding: 4px 8px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgb(224, 221, 221);
}
.goods-img {
  padding: 5px;
}
.goods-img img {
  width: 80px;
  height: 110px;
  border-radius: 5px;
}
.goods-info {
  width: 65%;
  padding: 5px 10px;
  overflow: hidden;
  font-size: 17px;
  color: #333;
}
.goods-info .title,
.goods-info .desc {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.goods-info .desc {
  margin-top: 10px;
  font-size: 14px;
  color: #666;
}
.goods-info .price_count {
  padding: 8px 5px;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
}
.price {
  color: var(--color-high-text);
  font-weight: 700;
}
</style>